package com.itheima.FactoryPattern;

public class Factory_demo {
    /**
     * 定义一个方法，创建对象返回
     */
    public static Computer factory(String info){
        switch (info){
            case "huawei":
                Computer c = new Huawei();
                c.setName("MateBook pro");
                c.setPrice(5799);
                return c;
            case "Mac":
                Computer c1 = new Mac();
                c1.setName("MacBook pro");
                c1.setPrice(8999);
                return c1;
            default:
                return null;
        }

    }
}
